/*
1.求一个数字数组里的最大连续数字的个数。
3, 4, 4, 4, 2, 2, 3, 4  =>  return 3
*/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

int getLongest(int num[], int size)
{
    int len = 0;
    vector<int> diff(size, 0);
    for (int i = 1; i < size; i++) 
        diff[i] = num[i] - num[i-1]; 
    for (int i = 0; i < diff.size(); i++)
	cout << diff[i] << " ";
    cout << endl;

    for (int i = 1; i < size; ) {
       if (diff[i] != 1) {i++; continue;}
       int count = 1;
       while (++i < size && diff[i] == 1) count++;
       len = max(len, count); 
    }
    return len+1;
}

int main(int argc, char **argv)
{
    //int num[] = {3, 4, 4, 4, 2, 2, 3, 4};
    int num[] = {3, 4, 4, 4, 2, 2, 3, 4,8,4,2,6,5,4,2,3,4,5,6,7,1,2,4,3,2};
    int size = getLongest(num, sizeof(num)/sizeof(int));
    cout << size << endl;
}
